//
//  GoodCateSubListCell.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/15.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "GoodCateSubListCell.h"

@interface GoodCateSubListCell ()

@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;

@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UILabel *middleLabel;

@property (weak, nonatomic) IBOutlet UILabel *bottomLabel;
@property (weak, nonatomic) IBOutlet UIButton *rightBtn;
@property (weak, nonatomic) IBOutlet UIView *proViewBottom;
@property (weak, nonatomic) IBOutlet UIView *proViewTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *proViewTopW;

@end

@implementation GoodCateSubListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor = [UIColor whiteColor];
    self.topLabel.font = SubTitleFont;
    
    self.middleLabel.font = DetailFont;
    self.middleLabel.textColor = darkGray;
    
    self.bottomLabel.font = DetailFont;
    self.bottomLabel.textColor = darkGray;
    
    self.proViewBottom.layer.cornerRadius = 3;
    self.proViewBottom.layer.masksToBounds = YES;
    
    self.rightBtn.layer.cornerRadius = 5;
    self.rightBtn.layer.masksToBounds = YES;
    self.rightBtn.layer.borderColor = themeColor.CGColor;
    self.rightBtn.layer.borderWidth = 0.6;
    
    [self.rightBtn setTitleColor:themeColor forState:UIControlStateNormal];
    [self.rightBtn setTitleColor:themeColor forState:UIControlStateHighlighted];
    self.rightBtn.titleLabel.font = SubTitleFont;
    // Initialization code
}


- (void)setModel:(GoodsInfoModel *)model{
    _model = model;
    
    self.topLabel.text = _model.goods_name;
    
    [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:_model.goods_image]];
    
    self.middleLabel.text = [NSString stringWithFormat:@"总需:%@人次次",_model.total_count];
    
    
    self.bottomLabel.attributedText = [self attributedString];
    
    
    self.proViewTopW.constant = (KScreenW - 108)/100.0 * _model.percent.floatValue;
    
    
}



- (NSMutableAttributedString *)attributedString{
    //    [NSString stringWithFormat:@"主营业务: %@",_model.desc];

    NSMutableAttributedString *attributeString6 = [[NSMutableAttributedString alloc] init];
    NSAttributedString *string26 = [[NSAttributedString alloc] initWithString:@"剩余:" attributes:@{NSFontAttributeName :DetailFont ,NSForegroundColorAttributeName : darkGray}];
    
    
    NSAttributedString *string27 = [[NSAttributedString alloc] initWithString:self.model.remain_count attributes:@{NSFontAttributeName : DetailFont,NSForegroundColorAttributeName : themeColor}];
    
    
    NSAttributedString *string29 = [[NSAttributedString alloc] initWithString:@"次" attributes:@{NSFontAttributeName :DetailFont ,NSForegroundColorAttributeName : darkGray}];

    
    
//    NSMutableParagraphStyle *para = [[NSMutableParagraphStyle alloc]init];
//
//    para.lineSpacing = 3;
    
    [attributeString6 appendAttributedString:string26];
    [attributeString6 appendAttributedString:string27];
    [attributeString6 appendAttributedString:string29];

//    [attributeString6 addAttribute:NSParagraphStyleAttributeName value:para range:NSMakeRange(0, attributeString6.length)];
    
    return attributeString6;
    
    
}




- (IBAction)rightBtnDidTap:(UIButton *)sender {
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
